package com.ruoyi.asms.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.asms.domain.InspectionTask;
import com.ruoyi.asms.domain.vo.ThisWeekFaultSQLVo;
import com.ruoyi.asms.mapper.InspectionTaskMapper;
import com.ruoyi.asms.service.IInspectionTaskService;
import com.ruoyi.common.core.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 巡检任务信息Service业务层处理
 * 
 * @author yfkj
 * @date 2021-10-21
 */
@Service
public class InspectionTaskServiceImpl extends ServiceImpl<InspectionTaskMapper, InspectionTask>  implements IInspectionTaskService
{
    @Autowired
    private InspectionTaskMapper inspectionTaskMapper;

    /**
     * 查询巡检任务信息
     * 
     * @param inspectionTaskId 巡检任务信息主键
     * @return 巡检任务信息
     */
    @Override
    public InspectionTask selectInspectionTaskByInspectionTaskId(Long inspectionTaskId)
    {
        return inspectionTaskMapper.selectInspectionTaskByInspectionTaskId(inspectionTaskId);
    }

    /**
     * 查询巡检任务信息列表
     * 
     * @param inspectionTask 巡检任务信息
     * @return 巡检任务信息
     */
    @Override
    public List<InspectionTask> selectInspectionTaskList(InspectionTask inspectionTask)
    {
        return inspectionTaskMapper.selectInspectionTaskList(inspectionTask);
    }

    /**
     * 新增巡检任务信息
     * 
     * @param inspectionTask 巡检任务信息
     * @return 结果
     */
    @Override
    public int insertInspectionTask(InspectionTask inspectionTask)
    {
        inspectionTask.setCreateTime(System.currentTimeMillis());
        inspectionTask.setCreateBy(SecurityUtils.getUsername());
        return inspectionTaskMapper.insertInspectionTask(inspectionTask);
    }

    /**
     * 修改巡检任务信息
     * 
     * @param inspectionTask 巡检任务信息
     * @return 结果
     */
    @Override
    public int updateInspectionTask(InspectionTask inspectionTask)
    {
        inspectionTask.setUpdateTime(System.currentTimeMillis());
        inspectionTask.setUpdateBy(SecurityUtils.getUsername());

        return inspectionTaskMapper.updateInspectionTask(inspectionTask);
    }

    /**
     * 批量删除巡检任务信息
     * 
     * @param inspectionTaskIds 需要删除的巡检任务信息主键
     * @return 结果
     */
    @Override
    public int deleteInspectionTaskByInspectionTaskIds(Long[] inspectionTaskIds)
    {
        return inspectionTaskMapper.deleteInspectionTaskByInspectionTaskIds(inspectionTaskIds);
    }

    /**
     * 删除巡检任务信息信息
     * 
     * @param inspectionTaskId 巡检任务信息主键
     * @return 结果
     */
    @Override
    public int deleteInspectionTaskByInspectionTaskId(Long inspectionTaskId)
    {
        return inspectionTaskMapper.deleteInspectionTaskByInspectionTaskId(inspectionTaskId);
    }

    @Override
    public List<ThisWeekFaultSQLVo> getOneWeekInspectionNum(Long startTime, Long endTime, Long mDeptId) {
        return inspectionTaskMapper.getOneWeekInspectionNum(startTime, endTime, mDeptId);
    }
}
